<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
	
	public function _initialize(){
		
	}
	
	//首页
    public function index(){
        $this->display();
    }
	
	//插入IP
	public function addip(){
		$param = json_decode($_POST['formdata']);
		$arr = [];
		$time = time();
		foreach($param as $v){
			$data = [];
			$data['ipid']      = ipton($v[0], array(), true);
			$data['ip']        = $v[0];
			$data['port']      = $v[1];
			$data['amlevel']   = $v[2];
			$data['ptype']     = $v[3];
			$data['position']  = $v[4];
			$data['source']    = $v[5];
			$data['add_time']  = $time;
			$arr[] = $data;
		}
		try {   
			$res = M("ip")->addAll($arr,[],true);
		} catch (Exception $e) {   
			 
		} 
		$this->outJson(["status"=>1]);
	}
	
	public function outJson($data){
		echo json_encode($data);	
	}
	
	//404页面
	public function _empty(){
		$this->site_url = My404();
        $this->display("Public:default:404");
	} 
	
}